Skip to main content

JDBC Driver Connection Strings for Java RESTful Engine

If the data source for your template is a database, you will need to provide a connection string in the request body. The connection string is a string that specifies information about the data source and the means of connecting to it. The connection string is used to establish a connection to the database and to access the data. Here we've provided example JDBC connection strings for SQLServer, MySQL, Oracle, DB2, and PostgreSQL databases.

If the data source for your template is not a database, you can skip this section.

This is a guide to structuring your connection strings for SQLServer, MySQL, Oracle and DB2 databases, along with an example request bodies for each. If you don't know how to construct a request body, please refer to the template section of our swagger documentation.

caution

In order for the Java RESTful Engine to connect to a database, a JDBC driver needs to be installed. For more information on how to obtain and install JDBC Drivers, check the JDBC Drivers Reference. Drivers for the following are included in the Java RESTful installation.

  • SQL Server
  • Oracle
  • DB2

SQL Server

In the request body, you want to have:

  • Type = ado
  • ClassName = com.microsoft.sqlserver.jdbc.SQLServerDriver The connection string should look like:
jdbc:sqlserver://{server_address};databaseName={database_name};username={username};password={password};

Here is an example request body:

<Template>
<ConnectionString>{template_connection_string}</ConnectionString>
<OutputFormat>pdf</OutputFormat>
<Datasources>
<Datasource>
<Name>{db_name}</Name>
<Type>ado</Type>
<ClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</ClassName>
<ConnectionString>jdbc:sqlserver://{server_address};databaseName={database_name};username={username};password={password};</ConnectionString>
</Datasource>
</Datasources>
</Template>

MySQL

In the request body, you want to have:

  • Type = ado
  • ClassName = com.mysql.cj.jdbc.Driver The connection string should look like:
jdbc:mysql://{server_address}/{server_name};username={username};password={password};

Here is an example request body:

<Template>
<ConnectionString>{template_connection_string}</ConnectionString>
<OutputFormat>pdf</OutputFormat>
<Datasources>
<Datasource>
<Name>{db_name}</Name>
<Type>ado</Type>
<ClassName>com.mysql.cj.jdbc.Driver</ClassName>
<ConnectionString>jdbc:mysql://{server_address}/{server_name};username={username};password={password};</ConnectionString>
</Datasource>
</Datasources>
</Template>

Oracle

In the request body, you want to have:

  • Type = ado
  • ClassName = oracle.jdbc.OracleDriver The connection string should look like:
jdbc:oracle:thin:@//{server_address};username={username};password={password};

Here is an example request body:

<Template>
<ConnectionString>{template_connection_string}</ConnectionString>
<OutputFormat>pdf</OutputFormat>
<Datasources>
<Datasource>
<Name>{db_name}</Name>
<Type>ado</Type>
<ClassName>oracle.jdbc.OracleDriver</ClassName>
<ConnectionString>jdbc:oracle:thin:@//{server_address};username={username};password={password};</ConnectionString>
</Datasource>
</Datasources>
</Template>

DB2

In the request body, you want to have:

  • Type = ado
  • ClassName = com.ibm.db2.jcc.DB2Driver The connection string should look like:
jdbc:db2://{server_address}/{server_name};username={username};password={password};

Here is an example request body:

<Template>
<ConnectionString>{template_connection_string}</ConnectionString>
<OutputFormat>pdf</OutputFormat>
<Datasources>
<Datasource>
<Name>{db_name}</Name>
<Type>ado</Type>
<ClassName>com.ibm.db2.jcc.DB2Driver</ClassName>
<ConnectionString>jdbc:db2://{server_address}/{server_name};username={username};password={password};</ConnectionString>
</Datasource>
</Datasources>
</Template>

PostgreSQL

caution

If you experience issues with connection to a POSTgreSQL database, you may need to place the JDBC driver in the Tomcat lib folder. You can see how to do this below the example request body.

In the request body, you want to have:

  • Type = ado
  • ClassName = org.postgresql.Driver

The connection string should look like:

jdbc:postgresql://{server_address}/{server_name};user={username};password={password};

Here is an example request body:

<Template>
<ConnectionString>{template_connection_string}</ConnectionString>
<OutputFormat>pdf</OutputFormat>
<Datasources>
<Datasource>
<Name>{db_name}</Name>
<Type>ado</Type>
<ClassName>org.postgresql.Driver</ClassName>
<ConnectionString>jdbc:postgresql://{server_address}/{server_name};user={username};password={password};</ConnectionString>
</Datasource>
</Datasources>
</Template>
Adding PostgreSQL connector to Tomcat
  1. Install the latest Java 8 PostgreSQL connector from their download page
  2. Place the .jar file in Tomcat's lib folder
    1. i.e. Windows: C:\Program Files\Apache Software Foundation\Tomcat 10.1\lib
    2. i.e. Linux: /usr/local/tomcat10-1/lib
  3. Restart your JavaRESTful Engine and you should be good to go!